﻿using Microsoft.Extensions.Logging;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CrystalQuartz.Demo.Jobs
{
    public class HelloQuartzJob : AbstractQuartzJob
    {
        private ILogger<HelloQuartzJob> _logger;
        public HelloQuartzJob(ILogger<HelloQuartzJob> logger)
        {
            _logger = logger;
        }

        public HelloQuartzJob()
        {

        }

        protected async override Task Execute(IJobExecutionContext context)
        {
            var color = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("HelloQuartzJob!");
            Console.ForegroundColor = color;
            _logger.LogInformation($"This is from {_logger?.GetType()}");

            var delaySeconds = TimeSpan.FromSeconds(1);

            await Task.Delay(delaySeconds);
        }
    }
}
